﻿using System.Xml;
using System.Xml.Serialization;
using System;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.Xml.Schema;

namespace ScormModel
{
    [Serializable()]
    public class PostConditionRule
    {
        private RuleConditions _ruleConditions;
        private RuleAction _ruleAction;
         [NonSerialized]
        private XmlNode _postConditionRuleContent;
        [XmlElement("ruleConditions", Namespace = "http://www.imsglobal.org/xsd/imsss")]
        public RuleConditions RuleConditions
        {
            get { return this._ruleConditions; }
            set { this._ruleConditions = value; }
        }
        [XmlElement("ruleAction", Namespace = "http://www.imsglobal.org/xsd/imsss")]
        public RuleAction RuleAction
        {
            get { return this._ruleAction; }
            set { this._ruleAction = value; }
        }
        
        [XmlIgnoreAttribute]
        public XmlNode PostConditionRuleContent
        {
            get { return this._postConditionRuleContent; }
            set { this._postConditionRuleContent = value; }
        }
        public void buildPostConditionRule()
        {
            XmlElement element = (XmlElement)_postConditionRuleContent;
            for (int i = 0; i < _postConditionRuleContent.ChildNodes.Count; i++)
            {
                if (_postConditionRuleContent.ChildNodes[i].Name == "imsss:ruleConditions")
                {
                    _ruleConditions = new RuleConditions();
                    _ruleConditions.RuleConditionsContent = _postConditionRuleContent.ChildNodes[i];
                    _ruleConditions.buildRuleConditions();
                }
                if (_postConditionRuleContent.ChildNodes[i].Name == "imsss:ruleAction")
                {
                    _ruleAction = new RuleAction();
                    _ruleAction.RuleActionContent = _postConditionRuleContent.ChildNodes[i];
                    _ruleAction.buildRuleAction();
                }
            }
        }
    }
}
